package com.wang.di.defalut.bean;


import com.wang.di.core.abs.AbstractNameBean;
import com.wang.di.core.exception.BeanInitException;
import com.wang.di.defalut.anno.SingleBeanAnno;

// 单例bean
public class SingleBean extends AbstractNameBean {
    private Object instance = null;

    public SingleBean(Class clz, SingleBeanAnno anno) {
        super(clz, anno);
    }

    @Override
    public Object get() throws BeanInitException {
        if (instance == null) {
            instance = this.create();
        }
        return instance;
    }
}
